package org.springblade.modules.repair.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.modules.repair.dto.ByScoreQuestionAppealSearchDTO;
import org.springblade.modules.repair.entity.MaintainByScoreQuestion;
import org.springblade.modules.repair.entity.MaintainByScoreQuestionAppeal;
import org.springblade.modules.repair.service.ByScoreQuestionAppealService;
import org.springblade.modules.repair.service.IMaintainByScoreQuestionService;
import org.springblade.modules.repair.vo.ByScoreQuestionAppealPageVO;
import org.springblade.modules.repair.vo.PlanAbarbeitungByContentVO;
import org.springframework.web.bind.annotation.*;

import javax.swing.text.WrappedPlainView;
import java.util.List;

/**
 * @Date 9:29 2025/5/20
 * @Description {
 *   保养评分问题申诉
 * }
 * @Author lsay
 **/
@AllArgsConstructor
@RestController
@RequestMapping("/by/score/question/appeal")
public class ByScoreQuestionAppealController {

	private final ByScoreQuestionAppealService byScoreQuestionAppealService;

	@GetMapping("/page")
	public R<IPage<ByScoreQuestionAppealPageVO>> page(Query query, ByScoreQuestionAppealSearchDTO searchDTO){
		return R.data(byScoreQuestionAppealService.selectPage(Condition.getPage(query),searchDTO));
	}

	@GetMapping("/detail")
	public R<MaintainByScoreQuestionAppeal> detail(Long id){
		return R.data(byScoreQuestionAppealService.getById(id));
	}

	@GetMapping("/detail/item")
	public R<List<PlanAbarbeitungByContentVO>> detailItem(Long id){
		return R.data(byScoreQuestionAppealService.selectDetailItem(id));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   提交问题申诉原因
	 * }
	 * @Date 8:44 2025/5/21
	 * @Param
	 * @return 成功与否
	 **/
	@PostMapping("/submit/reason")
	public R<Boolean> submitReason(@RequestBody MaintainByScoreQuestion byScoreQuestion){
		return R.data(byScoreQuestionAppealService.submitReason(byScoreQuestion));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *    申诉
	 * }
	 * @Date 8:51 2025/5/21
	 * @Param
	 * @return 成功与否
	 **/
	@PostMapping("/submit")
	public R<Boolean> submit(@RequestBody MaintainByScoreQuestionAppeal appeal){
		return R.data(byScoreQuestionAppealService.submit(appeal));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   申诉审核
	 * }
	 * @Date 8:52 2025/5/21
	 * @Param
	 * @return 成功与否
	 **/
	@PostMapping("/submit/result")
	public R<Boolean> submitResult(@RequestBody MaintainByScoreQuestionAppeal appeal){
		return R.data(byScoreQuestionAppealService.submitResult(appeal));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *    撤销申诉
	 * }
	 * @Date 8:51 2025/5/21
	 * @Param
	 * @return 成功与否
	 **/
	@PostMapping("/repeal")
	public R<Boolean> repeal(@RequestBody MaintainByScoreQuestionAppeal appeal){
		return R.data(byScoreQuestionAppealService.repeal(appeal));
	}

}
